package hk.linkcredit.walletservice.wallet.mapper;

import hk.linkcredit.walletservice.wallet.domain.entity.WalletAmount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 钱包金额表 Mapper 接口
 * </p>
 *
 * @author LinkCredit
 * @since 2022-06-10 01:23:44
 */
public interface WalletAmountMapper extends BaseMapper<WalletAmount> {

    @Select("select m.cust_no from (select cust_no, sum(amount) - sum(frozen_amount) from wallet_amount group by cust_no having sum(amount) - sum(frozen_amount) > 0) m")
    List<String> getCustomersWithBalance();
}
